import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home',
    name: 'inedx',
    component: () => import('../App'),
    meta: { title: '主1111页' },
    children: [
      {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/Home'),
        meta: { title: '主页' }
      },
      {
        path: '/home/register',
        name: 'register',
        component: () => import('@/views/auth/Register'),
        meta: { title: '注册' }
      },
      {
        path: '/home/login',
        name: 'login',
        component: () => import('@/views/auth/Login'),
        meta: { title: '登陆' }
      },
      {
        path: '/home/post/create',
        name: 'create',
        component: () => import('@/views/post/Create'),
        meta: { title: '发表文章', requireAuth: true }
      },
      {
        path: '/home/topic/edit/:id',
        name: 'topic-edit',
        component: () => import('@/views/post/Edit'),
        meta: { title: '编辑文章', requireAuth: true }
      },
      {
        path: '/home/post/:id',
        name: 'post-detail',
        component: () => import('@/views/post/Detail'),
        meta: { title: '发表详情' }
      },
      {
        path: '/home/tag/:name',
        name: 'tag',
        component: () => import('@/views/tag/Tag'),
        meta: { title: '相关文章' }
      },
      {
        path: '/home/search',
        name: 'search',
        component: () => import('@/views/Search'),
        meta: { title: '检索' }
      },
      {
        path: '/home/member/:username/homeIndex',
        name: 'user',
        component: () => import('@/views/user/Profile'),
        meta: { title: '用户主页', requireAuth: true }
      },
      {
        name: 'user-setting',
        path: '/home/member/:username/setting',
        component: () => import('@/views/user/Setting'),
        meta: { title: '设置', requireAuth: true }
      },
      {
        name: 'user-GroupIndex',
        path: '/home/member/:username/GroupIndex',
        // redirect: '/home/member/acc111/GroupIndex/home',
        component: () => import('@/views/Group/GroupIndex'),
        meta: { title: '群组中心', requireAuth: true }
      },
      {
        path: '/home/member/:username/GroupIndex/join:id',
        name: 'newGroup2',
        component: () => import('@/views/Group/JoinGroup'),
        meta: { title: 'join当前群', requireAuth: true },
        props: true
      },
      {
        path: '/home/member/:username/GroupIndex/set:id',
        name: 'newGroup',
        component: () => import('@/views/Group/setNewGroup'),
        meta: { title: 'set当前群', requireAuth: true },
        props: true
      },
      {
        path: '/home/404',
        name: '404',
        component: () => import('@/views/error/404'),
        meta: { title: '404-NotFound' }
      },
      {
        // http://localhost:8081/#/home/member/gva123/homeIndex
        path: '/home/*',
        redirect: '/home/404',
        hidden: true
      }

    ]
  },
  // ...........。。。。。。。。。。。。。。......后台页。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

  {
    path: '/text',
    name: '测试也',
    component: () => import('@/views/text'),
    meta: { title: '测试页' }
  },

  {
    name: 'userHoutai',
    path: '/houtai/x-login',
    component: () => import('@/houtai/login/Mlogin'),
    meta: { title: '后台登陆中心' }
  },
  {
    name: 'houtai-lauout',
    path: '/houtai',
    redirect: '/houtai/muser',
    component: () => import('@/houtai/Layout/layout'),
    children: [
      {
        path: '/houtai/muser',
        name: 'muser',
        component: () => import('@/houtai/Hviews/muser'),
        meta: { title: '用户管理中心', requireAuth: true }
      },
      {
        path: '/houtai/superUser',
        name: 'superUser',
        component: () => import('@/houtai/Hviews/superUser'),
        meta: { title: '管理员中心', requireAuth: true }
      },
      {
        path: '/houtai/article',
        name: 'article',
        component: () => import('@/houtai/Hviews/article'),
        meta: { title: '文章管理中心', requireAuth: true }
      },
      {
        path: '/houtai/lmess',
        name: 'lmess',
        component: () => import('@/houtai/Hviews/lmess'),
        meta: { title: '数据统计中心', requireAuth: true }
      },
      {
        path: '/houtai/apply',
        name: 'applyAB',
        component: () => import('@/houtai/Hviews/applyAB'),
        meta: { title: '申请中心', requireAuth: true }
      },
      {
        path: '/houtai/404Not',
        name: '404Not',
        component: () => import('@/views/error/404Houtai'),
        meta: { title: '404-NotFound' }
      },
      {
        // http://localhost:8081/#/home/member/gva123/homeIndex
        path: '/houtai/*',
        redirect: '/houtai/404Not',
        hidden: true
      }
    ]
  }

]

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch((err) => err)
}

const router = new VueRouter({
  routes
})

export default router
